<template>
	<view class="container bg-main pos-r">
		<view class="padding-xl dflex-c dflex-flow-c">
			<view class="portrait-box margin-bottom">
				<image class="headimg border-radius-c" :src="(userInfo && userInfo.avatar) || 'https://img.shihuashengyi.cn/static/images/user/default.png'"></image>
			</view>
			<view class="w-full dflex padding-bottom-sm">
				<view class="iconfont icongerenzhongxin- margin-right"></view>
				<view class="flex1 dflex">
					<input class="border-line padding-sm flex1"  v-model="user.realName" placeholder="请输入真实姓名" />
				</view>
			</view>
			<view class="w-full dflex padding-bottom-sm">
				<view class="iconfont iconshouji margin-right"></view>
				<view class="flex1 dflex">
					<input class="border-line padding-sm flex1"  v-model="user.documentNumber" placeholder="请输入身份证号码" />
				</view>
			</view>

			<view class="w-full dflex padding-bottom-sm">
				<view class="iconfont iconmima margin-right"></view>
				<input class="border-line padding-sm flex1" type="password" v-model="user.fundPassword"  placeholder="请输入新密码" />
			</view>
			<view class="w-full margin-top-xl">
				<view class="dflex-b border-radius-lg">
					<view class="tac padding-tb-sm flex1 bg-base fs" @click="submit">确定</view>
				</view>
			</view>
		</view>

		<!-- 世华圣医版权 -->
		<use-copyright class="pos-f w-full" style="bottom: -30rpx"></use-copyright>
	</view>
</template>

<script>
	import md5 from "@/common/SDK/md5.min.js";
	import {pay_password,user_authentication} from "../../../js_sdk/apis/user.js"
	export default {
		data() {
			return {
				user:{
					documentType:1,
					fundPassword:"",
					realName:"",
					documentNumber:"",
				}
			};
		},
		computed: {
			userInfo(){
				return this.$store.state.user.userInfo
			},
			isLogin(){
				return this.$store.getters['user/hasLogin']
			}
		},
		onLoad() {
			// user_authentication().then(res=>{
			// 	console.log(res.data.content)
			// })
		},
		methods: {
			submit() {
				let _this = this;
				if (!this.user.realName) {
					this.$api.msg('请输入真实姓名');
					return;
				}
				if (!this.user.documentNumber) {
					this.$api.msg('请输入身份证号');
					return;
				}
				if (!this.user.fundPassword) {
					this.$api.msg('fundPassword');
					return;
				}
				let send=Object.assign({},this.user)
				console.log(send)
				send.fundPassword=md5(send.fundPassword)
				pay_password(send).then(res=>{
					this.$api.msg('设置成功');
					this.$api.timerout(() => {
						uni.navigateBack();
					}, 1000);
					return;
				}).catch(err=>{
					console.log(err)
				})
			}
		}
	};
</script>

<style lang="scss">
	page {
		background: #f5f5f5;
	}

	.container {
		padding-top: 5vh;
		width: 100vw;
		min-height: 100vh;
		overflow: hidden;
	}

	.portrait-box {
		image {
			width: 130rpx;
			height: 130rpx;
			border: 5rpx solid #fff;
		}
	}
</style>
